import { Prisma } from '@prisma/client';
import { IsDefined, IsNotEmptyObject } from 'class-validator';
import { BaseDto, BaseFindDto, BaseQueryDto } from './base.dto';
import { Transform } from 'class-transformer';

export class CollectionCreateDto extends BaseDto<Prisma.CollectionCreateInput> {}

export class CollectionUpdateDto extends BaseDto<Prisma.CollectionUpdateInput> {
  @IsDefined({ message: '条件必填' })
  @IsNotEmptyObject({ nullable: false }, { message: '条件参数必填' })
  where: Prisma.CollectionWhereUniqueInput;
}

export class CollectionFindDto extends BaseFindDto<
  Prisma.CollectionWhereUniqueInput,
  Prisma.CollectionSelect
> {}

export class CollectionQueryDto extends BaseQueryDto<Prisma.CollectionWhereUniqueInput> {}

export class CollectionListDto extends BaseQueryDto<Prisma.CollectionWhereUniqueInput> {}

export class CollectionOrderQueryDto extends BaseQueryDto<
  Prisma.CollectionWhereUniqueInput & {
    startTime?: string;
    endTime?: string;
    total?: number;
    title?: string;
    realname?: string;
    mobile?: string;
  }
> {}

export class CollectionOrderDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;

  @IsDefined({ message: '密码必填' })
  pass: string;
}

export class CollectionReceiveDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;

  @IsDefined({ message: '地址必填' })
  @Transform(({ value }) => Number(value))
  addressId: number;
}

export class CollectionOrderReportDto extends BaseQueryDto<{
  startTime?: string;
  endTime?: string;
  collectionId?: number;
  title?: string;
}> {}
